<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="../templates/layout.xhtml">
	<ui:define name="content">
		<h:form prependId="false" id="growlForm">
			<p:growl id="growl" showDetail="true" />
		</h:form>
		<h:form id="controlForm" prependId="false">
			<p:panel id="provinsiPanel">
				<f:facet name="header">
					<h:outputText value="provinsi" />
				</f:facet>
				<h:outputFormat id="noRecordsFound"
					value="#{messages.label_no_records_found}"
					rendered="#{!provinsiBean.dataVisible}">
					<f:param value="provinsi" />
				</h:outputFormat>
				<h:panelGrid columns="2" columnClasses="col1,col2" rendered="#{provinsiBean.dataVisible}">
					<h:outputText value="Nama provinsi: "/><h:outputText value="#{provinsiBean.provinsi.name}"/>
					<h:outputText value="Kode: "/><h:outputText value="#{provinsiBean.provinsi.code}"/>
				</h:panelGrid>
				
				<p:separator/>
				<p:commandButton value="Buat baru" 
					action="#{provinsiBean.displayNew}"
					icon="ui-icon-document" id="createButton" 
					rendered="#{!provinsiBean.dataVisible}"
					oncomplete="createDialog.show()" update=":createForm:createPanelGrid"/>
					<p:commandButton id="editButton" icon="ui-icon-pencil"
							action="#{provinsiBean.displayEdit}"
							oncomplete="createDialog.show()"
							title="#{messages.label_edit}"
							update=":createForm:createPanelGrid">
							
						</p:commandButton>
						<p:commandButton id="deleteButton" icon="ui-icon-trash"
							oncomplete="deleteDialog.show()" title="#{messages.label_delete}">
							<f:setPropertyActionListener target="#{provinsiBean.provinsi}"
								value="#{provinsi}" />
						</p:commandButton>
			</p:panel>
		</h:form>
		<p:dialog id="createDialog" header="Buat provinsi/Kota" 
			modal="true" widgetVar="createDialog" 
			dynamic="true" resizable="true" maximizable="true" showEffect="fade" hideEffect="fade">
     	 <p:outputPanel id="createPanel">
        	<h:form id="createForm">
         		 <h:panelGrid id="createPanelGrid" columns="3" styleClass="dialog" columnClasses="col1,col2,col3">        		 
         		 <h:outputLabel for="name" value="Nama provinsi/kota: "/>
         		 <h:inputText id="name" value="#{provinsiBean.provinsi.name}" required="true"/>
         		 <p:message for="name"/>
         		 <h:outputLabel for="code" value="Kode: "/>
         		 <h:inputText id="code" value="#{provinsiBean.provinsi.code}" required="true"/>
         		 <p:message for="code"/>
         		 </h:panelGrid>
         		 <h:panelGrid columns="2" columnClasses="col1,col2">
         		  <p:commandButton id="createSaveButton" value="#{messages.label_save}" action="#{provinsiBean.save}" update="createPanelGrid :controlForm :growlForm:growl" oncomplete="createDialog.hide()"/>
         		 <p:commandButton id="createCloseButton" value="#{messages.label_close}" onclick="createDialog.hide()" type="button" action="#{provinsiBean.clear}" update="createPanelGrid"/>
         		 </h:panelGrid>
       		 </h:form>
      </p:outputPanel>
      </p:dialog>
      <p:confirmDialog id="deleteDialog" widgetVar="deleteDialog"
			message="#{messages.label_delete_record}" showEffect="fade"
			hideEffect="explode" header="#{messages.label_confirm_deletion}"
			severity="alarm">
			<p:outputPanel id="deletePanel">
				<h:form id="deleteForm">
					<p:commandButton id="deleteYesButton" value="#{messages.label_yes}"
						action="#{provinsiBean.delete}"
						update=":controlForm :growlForm:growl"
						oncomplete="deleteDialog.hide()" />
					<p:commandButton id="deleteNoButton" value="#{messages.label_no}"
						onclick="deleteDialog.hide()" type="button" />
				</h:form>
			</p:outputPanel>
		</p:confirmDialog>
	</ui:define>
</ui:composition>
</html>